package com.order.conttroller;

import com.example.order.Order;
import com.example.product.Product;
import com.order.properties.OrderProperties;
import com.order.services.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.util.List;

@RestController
public class OrderController {


    @Autowired
    OrderService orderService;


    @Autowired
    OrderProperties orderProperties;

    @GetMapping("/create")
    public Order createOrder(@RequestParam("productId") Long productId,
                             @RequestParam("userId") Long userId) {


        return orderService.createOrder(productId, userId);
    }

    @GetMapping("/config")
    public String getConfig() {
      System.out.println("aatest qasdwnishubushiasdbhgkjqwei asjbujwehruewd");
      return orderProperties.getTimeout() + "---" + orderProperties.getIsDebug();
    }


}

